export const cache = {
  getToken: () => localStorage.getItem('token'),
  setToken: (token: string) => localStorage.setItem('token', token),

  getTgUser: () => (localStorage.getItem('tgUser') ? JSON.parse(localStorage.getItem('tgUser')!) : null) as TgUser,
  setTgUser: (tgUser: TgUser) => localStorage.setItem('tgUser', JSON.stringify(tgUser)),

  getTokenExpires: () => parseInt(localStorage.getItem('tokenExpires') || '0'),
  setTokenExpires: (tokenExpires: number) => localStorage.setItem('tokenExpires', tokenExpires + ''),

  getRefreshToken: () => localStorage.getItem('refreshToken'),
  setRefreshToken: (refreshToken: string) => localStorage.setItem('refreshToken', refreshToken),

  getShop: () => (localStorage.getItem('store') ? JSON.parse(localStorage.getItem('store')!) : null) as ApiShop,
  setShop: (shop: ApiShop) => localStorage.setItem('store', JSON.stringify(shop))
}
